package org.langqiao.experiment.experiment3;
import java.util.*;
public class Circle{
       public static void main(String[] args){
              int[] a = new int[50];
              int n,m = 0;
              System.out.println("input a total number of people");
              Scanner sc =  new Scanner(System.in);
              n = sc.nextInt();
              for(int i = 0;i < n;i++)
                  a[i] = i + 1;
              int j = 0,num = 0;
              while(m < n - 1){
                    if(a[j] != 0) num ++;
                    if(num == 3){
                       a[j] = 0;
                       m ++;
                       num = 0;
                    }
                    j ++;
                    if(j == n)  j = 0;
              }
              for(int i = 0;i < n;i ++)
                  if(a[i] != 0)
                     System.out.println(a[i]);
        }
}